package com.centit.framework.ip.businessdata.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.centit.framework.ip.businessdata.dao.TodoItemDao;
import com.centit.framework.ip.businessdata.po.TodoItem;
import com.centit.framework.ip.businessdata.service.TodoItemManager;
import com.centit.framework.jdbc.service.BaseEntityManagerImpl;
import com.centit.support.database.utils.PageDesc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * TodoItem  Service.
 * create by scaffold 2018-06-04
 *
 * @author guo_jh
 * T_TODO_ITEM各个系统待办事项数据表
 */
@Service
public class TodoItemManagerImpl
        extends BaseEntityManagerImpl<TodoItem, String, TodoItemDao>
        implements TodoItemManager {

    public static final Log log = LogFactory.getLog(TodoItemManager.class);


    private TodoItemDao todoItemDao;

    @Resource(name = "todoItemDao")
    @NotNull
    public void setTodoItemDao(TodoItemDao baseDao) {
        this.todoItemDao = baseDao;
        setBaseDao(this.todoItemDao);
    }

    /*
         @PostConstruct
        public void init() {

        }

     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public JSONArray listTodoItemsAsJson(
            String[] fields,
            Map<String, Object> filterMap, PageDesc pageDesc) {

        return null;
    }

    /**
     * 根据子系统待办事项ID更新待办数据为已办
     *
     * @param id 子系统事项ID
     * @return 操作结果,false：未更新到数据
     */
    public boolean updateObject(String id){
        int result = this.todoItemDao.updateObject(id);
        if(result>0){
            return true;
        }else{
            return false;
        }
    }

}

